package com.amkai.aes.webservice.binary.objecthandler.registration;

import java.io.Serializable;

import com.amkai.aes.aescommon.contract.ContractManager;
import com.amkai.aes.aescommon.service.binary.job.registration.InsurancePlanJob;
import com.amkai.aes.generatedbeans.contract.Contract;
import com.amkai.aes.generatedbeans.insurance.InsurancePlan;
import com.amkai.aes.webservice.binary.JobObjectHandler;
import com.amkai.common.extensions.hibernate.config.SiteManager;
import com.amkai.common.extensions.hibernate.config.manager.SessionManager;

public class InsurancePlanHandler implements JobObjectHandler<InsurancePlanJob, Serializable, InsurancePlan> {

	@Override
	public InsurancePlan process(InsurancePlanJob job, Serializable object) throws Exception {
		SessionManager sm = SiteManager.Start();
		InsurancePlan ip = sm.get(InsurancePlan.class, job.getInsurancePlanId());
		ip.getInsuranceCarrier().getName();
		if (ip != null){
			for(Contract c : ip.getContracts()){
				ContractManager.loadContract(c);
				c.getComments();
				if(c.getPhone() != null){
					c.getPhone().getNumber();
				}
				
			}
		}
		return ip;
	}

}
